* Replication data for "The International Politics of Incomplete Sovereignty" *


***********************
* MAIN ARTICLE TABLES *
***********************

*Table 1: National-Level Validity Checks for Myers Index
use "hostile_neighbors_nationalvalidity.dta", clear

pwcorr 	myers_mean rgdppc_mean infant_mean  adultlit_mean  primaryenroll_mean ///
		icrg_mea  intconflict_mean bureau_mean ge_mean ps_mean rl_mean rq_mean cc_mean ///
		fsi_mean services_mean security_mean bti_mean stateness_mean, ///
		sig obs

*Table 2: Subnational-Level Validity Checks for Myers Index
use "hostile_neighbors_subnationalvalidity.dta", clear
pwcorr myers gdppc illit  if ccode == 140, sig obs // Brazil
pwcorr myers gdppc imr roaddensity teacherstudent if ccode==710, sig obs // China 
pwcorr myers gdppc imr villageroads literacy if ccode==750, sig obs // India
pwcorr myers gdppc post security if ccode==850, sig obs // Indonesia 
pwcorr myers gdppc imr literacy if ccode==640, sig obs //Turkey 

use "hostile_neighbors_birthreg.dta", clear
pwcorr myers registered, sig obs

**************************************************
use "hostile_neighbors_data_2017-04-28.dta", clear

*Table 3: Descriptive Statistics
univar lmyers rivalry lslopedness ldistance ldensity ethadjsplit_predominant humanpercent petro_percent capital

*Table 4: Effect of Hostility on State Authority
xtset ccodeyear geocode
eststo clear
eststo: xtreg lmyers_std rivalry, fe cluster(ccodeyear)
eststo: xtreg lmyers_std rivalry lslopedness_std ldistance_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital, fe cluster(ccodeyear)
esttab using table_4.tex, replace se label star(+ 0.10 * 0.05 ** 0.01) nomtitle addnote("Country-year intercepts suppressed")

*Table 5: Effect of Hostility within Provinces over Time
xtset ccoderegion year
eststo clear
eststo: xtreg lmyers_std rivalry year, fe cluster(ccoderegion)
eststo: xtreg lmyers_std rivalry ldensity_std year, fe cluster(ccoderegion)
esttab using table_5.tex, replace se label star(+ 0.10 * 0.05 ** 0.01) nomtitle addnote("Province intercepts suppressed")


************************
* MAIN ARTICLE FIGURES *
************************

use "hostile_neighbors_age_curves.dta", clear

*Figure 1: Two Regions in Mali, 1998
graph twoway scatter count age if regionname=="Sikasso", ytitle("Frequency") xtitle("Age")
graph export "figure_1a.png", replace

graph twoway scatter count age if regionname=="Gao", ytitle("Frequency") xtitle("Age")
graph export "figure_1b.png", replace


**************************
* ONLINE APPENDIX TABLES *
**************************

use "hostile_neighbors_data_2017-04-28.dta", clear

*Table A3.2: Correlations for Variables
label variable lmyers "Myers"
label variable rivalry "Rivalry"
label variable lslopedness "Terrain"
label variable ldistance "Distance"
label variable ldensity "Density"
label variable humanpercent "Development"
label variable petro_percent "Resources"
label variable capital "Capital"

corrtex 	lmyers rivalry lslopedness ldistance ldensity ethadjsplit_predominant humanpercent petro_percent capital, ///
			file(table_a3-2) replace sig

*Table A4.1: Robustness Checks
xtset ccodeyear geocode
eststo clear
eststo: xtreg lmyers_std rivalry lslopedness_std ldistance_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital larea_std, fe cluster(ccodeyear)
xtset ccode geocode
eststo: xtreg lmyers_std rivalry lslopedness_std ldistance_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital i.year, fe cluster(ccode)
xtset ccoderegion year
eststo: xtreg lmyers_std rivalry ldensity_std i.year, fe cluster(ccoderegion)
esttab using table_a4-1.tex, replace se label star(+ 0.10 * 0.05 ** 0.01) nomtitle drop(*.year) addnote("Intercepts suppressed")

*Table A5.1: Effect of Hostility on State Control
xtset ccodeyear geocode
eststo clear
eststo: xtreg lmyers_std rivalry lslopedness_std ldistance_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital, fe cluster(ccodeyear)
eststo: xtreg lmyers_std i.capratio_category lslopedness_std ldistance_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital if year<=2007, fe cluster(ccodeyear)
esttab using table_a5-1.tex, replace se label star(+ 0.10 * 0.05 ** 0.01) nomtitle nobase addnote("The omitted category in Column 2 is no rivalry")

*Table A5.2: Effect of Rivalry Conditional on Distance from the Capital
eststo clear
eststo: xtreg lmyers_std rivalry#distance_tertiles lslopedness_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital, fe cluster(ccodeyear)
esttab using table_a5-2.tex, replace se label star(+ 0.10 * 0.05 ** 0.01) interaction(*) nomtitle addnote("Country-year intercepts suppressed" "The omitted category is no rivalry*1st distance tercile")

***********************************************************
use "hostile_neighbors_data_insurgencies_2017-04-28", clear

*Table A5.3: Rivalry and Externally-Supported Insurgency, 1989-2008
tab rivalry extconflict

*Table A5.4: State Authority Means, 1989-2008
ttest lmyers_avg, by(conflictdummy2)

*Table A5.5: State Authority Means, 1989-2008
ttest lmyers_avg if conflictdummy2 == 1 & any_external==1, by(extrival)

**************************************************
use "hostile_neighbors_data_2017-04-28.dta", clear

*Table A5.6: Robustness to Excluding Interventionary Rivalries
eststo clear
eststo: xtreg lmyers_std notinterventionaryindicator lslopedness_std ldistance_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital, fe cluster(ccodeyear)
esttab using table_a5-6.tex, replace se label star(+ 0.10 * 0.05 ** 0.01) nomtitle addnote("Country-year intercepts suppressed")

*Table A5.7: Comparison of Effect of Hostile Neighbors by Herbst Political Geographies
ttest lmyers if difficult==1, by(rivalry)
ttest lmyers if neutral==1, by(rivalry)
ttest lmyers if hinterland==1, by(rivalry)
ttest lmyers if favorable==1, by(rivalry)


*Table A5.8: Regession Results with Alternative Proxies of Development
label variable humanpercent_std "Human economic activity"
label variable landsuit_std "Land suitability" 
eststo clear
eststo: xtreg lmyers_std rivalry lslopedness_std ldistance_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital, fe cluster(ccodeyear)
eststo: xtreg lmyers_std rivalry lslopedness_std ldistance_std ldensity_std ethadjsplit_predominant landsuit_std petro_percent_std capital, fe cluster(ccodeyear)
esttab using table_a5-8.tex, replace se label star(+ 0.10 * 0.05 ** 0.01) nomtitle addnote("Country-year intercepts suppressed")


***************************
* ONLINE APPENDIX FIGURES *
***************************

use "hostile_neighbors_data_2017-04-28.dta", clear

*Figure A4.1: Histogram of Rivalry Coefficients
gen beta = .
gen se = .
gen predictors = ""
tuples lslopedness_std ldistance_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital larea_std 

qui forvalues i = 1/`ntuples' {
	xtreg lmyers_std rivalry `tuple`i'', fe cluster(ccodeyear)
	replace beta = _b[rivalry] in `i'
	replace se = _se[rivalry] in `i'
    replace predictors = "`tuple`i''" in `i'
    }
gen p = wordcount(predictors) if predictors != ""
gen t = beta/se
gen pvalue = 2*ttail(e(df_r),abs(t))
gen significant = .
replace significant = 0 if pvalue>=.1
replace significant = 1 if pvalue>=0.05 & pvalue<.1
replace significant = 2 if pvalue<0.05
replace significant = . if beta == .

hist beta, xlabel(.04(.01).08) freq
graph export "figure_a4-1.png", replace

*Figure A4.2: Sample Sensitivity
gen beta2 = .
gen se2 = .
gen droppedcountry = ""
levelsof ccode, local(levelsccode)
foreach l of local levelsccode {
xtreg lmyers_std rivalry lslopedness_std ldistance_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital if ccode!=`l', fe cluster(ccodeyear)
replace beta2 = _b[rivalry] in `l'
replace se2 = _se[rivalry] in `l'
replace droppedcountry = "`l'" in `l'
    }
gen t2 = beta2/se2
gen pvalue2 = 2*ttail(e(df_r),abs(t2))
gen min2 = beta2 - invttail(e(df_r),0.025)*se2
gen max2 = beta2 + invttail(e(df_r),0.025)*se2
gen significant2 = .
replace significant2 = 0 if pvalue2>=.1 & pvalue2!=.
replace significant2 = 1 if pvalue2>=0.05 & pvalue2<.1
replace significant2 = 2 if pvalue2<0.05
gen droppedccode = droppedcountry
destring droppedccode,replace
destring droppedcountry, replace
kountry droppedcountry, from(cown)
rename NAMES_STD droppedname

list droppedname beta2 se2 pvalue2 if beta2!=.

rename beta2 estimate
gen temp2 = 1 if droppedccode!=.
replace temp2 = 2 if droppedccode==.
sort temp2 droppedname 
gen group = _n
replace group = . if droppedccode==.
drop temp2

labmask group, values(droppedname)
eclplot estimate min2 max2 group, horizontal xline(0) xlabel(-.05(.05).10) ylabel(1(1)78) xsize(5) ysize(11) ytitle(Dropped Country) xtitle(Parameter Estimate)
graph export "figure_a4-2.png", replace

*Figure A5.1: Diagnostic Scatter Plots
xtreg lmyers_std lslopedness_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital, fe cluster(ccodeyear)
predict r_diagnostic, res

graph twoway ///
	(scatter r_diagnostic ldistance if rivalry==0, msymbol(Oh) mcolor(black)) ///
	(lfit r_diagnostic ldistance if rivalry==0, lcolor(navy)) ///
	(lowess r_diagnostic ldistance if rivalry==0, lcolor(maroon) lpattern(dash)), ///
	xtitle(Logged Distance) ytitle(Logged Myers) xlabel(1(1)8) ylabel(-3(1)3) ///
	legend(col(3) label(1 "Residuals") label(2 "Linear regression") label(3 "LOESS"))
graph export "figure_a5-1a.png", replace	
	
graph twoway ///
	(scatter r_diagnostic ldistance if rivalry==1, msymbol(Oh) mcolor(black)) ///
	(lfit r_diagnostic ldistance if rivalry==1, lcolor(navy)) ///
	(lowess r_diagnostic ldistance if rivalry==1, lcolor(maroon) lpattern(dash)), ///
	xtitle(Logged Distance) ytitle(Logged Myers) xlabel(1(1)8) ylabel(-3(1)3) ///
	legend(col(3) label(1 "Residuals") label(2 "Linear regression") label(3 "LOESS"))
graph export "figure_a5-1b.png", replace	
	
*Figure A5.2: Distribution of Observations
gen riv2 = "Rivalry" if rivalry==1
replace riv2 = "No rivalry" if rivalry==0
graph hbox ldistance, nooutsides over(riv2) box(1, color(black)) marker(1, mcolor(black)) intensity(0) ytitle(Logged Distance) ylabel(1(1)8)
graph export "figure_a5-2.png", replace

*Figure A5.3: Conditional Marginal Effects of Rivalry
xtreg lmyers_std rivalry#distance_tertiles lslopedness_std ldensity_std ethadjsplit_predominant humanpercent_std petro_percent_std capital, fe cluster(ccodeyear)
margins, dydx(rivalry) at(distance_tertiles=(1(1)3)) vsquish
marginsplot, yline(0) xtitle(Distance Terciles) ytitle(Effects on Linear Prediction of Logged Myers) title("") xlabel(1(1)3)
graph export "figure_a5-3.png", replace

*********************************************
use "hostile_neighbors_age_curves.dta", clear

*Figure A6.1: The Effect of Demographic Shocks
graph twoway scatter count age if regionname=="Ile-de-France", ytitle("Frequency") xtitle("Age")
graph export "figure_a6-1a.png", replace

graph twoway scatter count age if regionname=="Gao", ytitle("Frequency") xtitle("Age")
graph export "figure_a6-1b.png", replace
